﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import Events.*;
    import Display.*;
    import Classes.virals.*;

    public class FranchiseViralManager {

        public static const VIRAL_EMPTYLOT:int = 0;
        public static const VIRAL_APPROVEBUILDINGREQUEST:int = 1;
        public static const VIRAL_ACCEPTEDBUILDING:int = 2;
        public static const VIRAL_DECLINEDBUILDING:int = 3;
        public static const VIRAL_REMOVEDBUILDING:int = 4;
        public static const VIRAL_STARRATINGINCREASED:int = 5;
        public static const VIRAL_GROWHQ_FIRST:int = 6;
        public static const VIRAL_GROWHQ_NEXT:int = 7;
        public static const VIRAL_GROWHQ_LAST:int = 8;
        public static const VIRAL_REMINDERACCEPTBONUS:int = 9;

        private static var m_ViralType:int = -1;
        private static var m_FranchiseType:String = "";
        private static var m_NeighborID:String = "";
        private static var m_ReminderArray:Array = new Array();
        private static var m_NewStarRating:Number = 0;
        private static var m_FranchiseName:String = "";

        public static function checkStarRatingEarned(_arg1:Number, _arg2:Number, _arg3:Number):Boolean{
            if ((((_arg1 < _arg3)) && ((_arg2 >= _arg3)))){
                return (true);
            };
            return (false);
        }
        public static function triggerFranchiseViralFeeds(_arg1:int, _arg2:String="", _arg3:String="", _arg4:Array=null, _arg5:Number=0, _arg6:Business=null):void{
            var _local19:Item;
            var _local7:Boolean;
            m_ViralType = _arg1;
            var _local8 = "";
            m_FranchiseType = _arg2;
            m_NeighborID = _arg3;
            m_NewStarRating = 0;
            var _local9 = "";
            var _local10 = "";
            var _local11 = "assets/dialogs/feeds/feed_cityseal.png";
            var _local12:int = GenericPopup.TYPE_SHARECANCEL;
            var _local13:String = Global.player.cityName;
            var _local14:String = Global.getVisiting();
            var _local15:String = Global.player.getFriendFirstName(_local14);
            var _local16:String = Global.player.getFriendCityName(_local14);
            var _local17 = "";
            var _local18 = "";
            if (m_FranchiseType.length > 0){
                _local19 = Global.gameSettings.getItemByName(m_FranchiseType);
                if ((((_local19.type == "business")) && (_arg6))){
                    _local17 = _arg6.getFranchiseName();
                    m_FranchiseName = _local17;
                } else {
                    if (m_NeighborID.length > 0){
                        _local17 = Global.franchiseManager.model.getDefaultFranchiseName(m_FranchiseType, m_NeighborID);
                        m_FranchiseName = _local17;
                    } else {
                        if (_local19.type == "business"){
                            m_FranchiseName = Global.franchiseManager.model.getFranchiseName(m_FranchiseType);
                        } else {
                            _local18 = ZLoc.t("Items", (_local19.name + "_friendlyName"));
                            m_FranchiseName = _local17;
                        };
                    };
                };
            };
            if (_arg3.length > 0){
                _local15 = Global.franchiseManager.getMapOwnerFirstName(_arg3);
            };
            if ((((((m_ViralType == VIRAL_STARRATINGINCREASED)) && ((m_NeighborID.length > 0)))) && ((m_FranchiseType.length > 0)))){
                m_NewStarRating = _arg5;
            };
            switch (m_ViralType){
                case VIRAL_EMPTYLOT:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_EmptyLot_prompt", {cityname:_local13});
                    _local10 = "viralFranchise_EmptyLot";
                    _local11 = "assets/dialogs/feeds/feed_owneracceptsfranchise.png";
                    _local8 = ViralType.FRANCHISE_EMPTY_LOT;
                    _local7 = false;
                    break;
                case VIRAL_APPROVEBUILDINGREQUEST:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_ApproveBuildingRequest_prompt", {friendName:_local15});
                    _local10 = "viralFranchise_ApproveBuildingRequest";
                    _local11 = "assets/dialogs/feeds/feed_needsapproval.png";
                    _local8 = ViralType.FRANCHISE_BUILDING_REQUEST;
                    break;
                case VIRAL_ACCEPTEDBUILDING:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_AcceptBuilding_prompt", {
                        franchiseName:_local17,
                        friendName:_local15
                    });
                    _local10 = "viralFranchise_AcceptBuilding";
                    _local11 = "assets/dialogs/feeds/feed_owneracceptsfranchise.png";
                    _local8 = ViralType.FRANCHISE_ACCEPTED_BUILDING;
                    break;
                case VIRAL_DECLINEDBUILDING:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_DeclineBuilding_prompt", {
                        friendName:_local15,
                        cityname:_local13,
                        franchiseName:_local17
                    });
                    _local10 = "viralFranchise_DeclineBuilding";
                    _local11 = "assets/dialogs/feeds/feed_franchisedeclined.png";
                    _local8 = ViralType.FRANCHISE_DECLINED_BUILDING;
                    break;
                case VIRAL_REMOVEDBUILDING:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_RemoveBuilding_prompt", {
                        friendName:_local15,
                        cityname:_local13
                    });
                    _local10 = "viralFranchise_RemoveBuilding";
                    _local11 = "assets/dialogs/feeds/feed_removefranchise.png";
                    _local8 = ViralType.FRANCHISE_REMOVED_BUILDING;
                    break;
                case VIRAL_GROWHQ_FIRST:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_GrowHQ1_prompt");
                    _local10 = "viralFranchise_GrowHQ1";
                    _local11 = "assets/dialogs/feeds/feed_growheadquarters.png";
                    _local8 = ViralType.FRANCHISE_GROW_HQ;
                    _local12 = GenericPopup.TYPE_OK;
                    _local7 = false;
                    break;
                case VIRAL_GROWHQ_NEXT:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_GrowHQ2_prompt");
                    _local10 = "viralFranchise_GrowHQ2";
                    _local11 = "assets/dialogs/feeds/feed_growheadquarters.png";
                    _local8 = ViralType.FRANCHISE_GROW_HQ;
                    _local7 = false;
                    break;
                case VIRAL_GROWHQ_LAST:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_GrowHQ3_prompt", {businessType:m_FranchiseName});
                    _local10 = "viralFranchise_GrowHQ3";
                    _local11 = "assets/dialogs/feeds/feed_growheadquarters.png";
                    _local8 = ViralType.FRANCHISE_GROW_HQ;
                    break;
                case VIRAL_STARRATINGINCREASED:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_StarUp_prompt", {
                        businessType:m_FranchiseName,
                        friendName:_local15
                    });
                    _local10 = "viralFranchise_StarUp";
                    _local11 = "assets/dialogs/feeds/feed_starratingincrease.png";
                    _local8 = ViralType.FRANCHISE_STAR_RATING_INCREASED;
                    break;
                case VIRAL_REMINDERACCEPTBONUS:
                    _local9 = ZLoc.t("Dialogs", "viralFranchise_BonusRemindSent_prompt_single", {friendName:_local15});
                    _local10 = "viralFranchise_BonusRemindSent";
                    _local11 = "assets/dialogs/feeds/feed_remindertoaccept.png";
                    _local8 = ViralType.FRANCHISE_BONUS_REMIND_ACCEPT;
                    break;
            };
            UI.displayViralShareMessage(_local8, _local9, _local12, onViralDialogClosed, _local10, true, _local11, _local10, 0, "", true, _local7);
        }
        private static function onViralDialogClosed(_arg1:GenericPopupEvent):void{
            var _local8:Item;
            _arg1.target.removeEventListener(GenericPopupEvent.SELECTED, onViralDialogClosed);
            if (_arg1.button != GenericPopup.YES){
                return;
            };
            var _local2:String = Global.player.cityName;
            var _local3:String = Global.getVisiting();
            var _local4:String = Global.player.getFriendFirstName(_local3);
            var _local5:String = Global.player.getFriendCityName(_local3);
            var _local6:String = m_FranchiseName;
            var _local7 = "";
            if (m_FranchiseType.length > 0){
                _local8 = Global.gameSettings.getItemByName(m_FranchiseType);
                if (_local8.type == "business"){
                    _local7 = ZLoc.t("Items", (_local8.name + "_friendlyName"));
                };
            };
            if (m_NeighborID.length > 0){
                _local3 = m_NeighborID;
                _local4 = Global.player.getFriendFirstName(m_NeighborID);
            };
            switch (m_ViralType){
                case VIRAL_EMPTYLOT:
                    Global.world.viralMgr.sendFranchiseFeed_EmptyLot(Global.player, Global.player.cityName);
                    break;
                case VIRAL_APPROVEBUILDINGREQUEST:
                    Global.world.viralMgr.sendFranchiseFeed_BuildingRequest(_local6, _local3);
                    break;
                case VIRAL_ACCEPTEDBUILDING:
                    Global.world.viralMgr.sendFranchiseFeed_AcceptedBuilding(_local2, _local6, _local3);
                    break;
                case VIRAL_DECLINEDBUILDING:
                    Global.world.viralMgr.sendFranchiseFeed_DeclinedBuilding(_local2, _local6, _local3);
                    break;
                case VIRAL_REMOVEDBUILDING:
                    Global.world.viralMgr.sendFranchiseFeed_RemovedBuilding(_local2, _local6, _local3);
                    break;
                case VIRAL_STARRATINGINCREASED:
                    Global.world.viralMgr.sendFranchiseFeed_StarRatingIncreased(Global.player, _local5, _local6, m_NewStarRating);
                    break;
                case VIRAL_GROWHQ_NEXT:
                    Global.world.viralMgr.sendFranchiseFeed_GrowHQ(Global.player, _local6);
                    break;
                case VIRAL_GROWHQ_LAST:
                    Global.world.viralMgr.sendFranchiseFeed_GrowHQ(Global.player, _local6);
                    break;
                case VIRAL_REMINDERACCEPTBONUS:
                    Global.world.viralMgr.sendFranchiseFeed_ReminderAcceptBonus(_local5, _local6, _local3, _local5);
                    break;
            };
        }

    }
}//package Classes 
